
const getAddress = function getAddress (lng, lat) {
  return new Promise((resolve, reject) => {
   //  debugger

    var geolocation = new BMap.Geolocation()
    geolocation.getCurrentPosition((r) => {
      var map = new BMap.Map('l-map')
      map.clearOverlays()
      // map.centerAndZoom('广州', 12)
      map.enableScrollWheelZoom() // 启用滚轮放大缩小，默认禁用
      map.enableContinuousZoom() // 启用地图惯性拖拽，默认禁用
      console.log('lng, lat=', lng, lat)
      var new_point = new BMap.Point(lng, lat)
      map.centerAndZoom(new_point, 20)
      var mk = new BMap.Marker(new_point)
      map.addOverlay(mk)
      map.panTo(new_point)
       // 经纬度
      var geoc = new BMap.Geocoder()
      geoc.getLocation(new_point, (rs) => {
        var addComp = rs.addressComponents
        console.log('addComp---', addComp)
           // 地址名称
        var currentAddress = addComp.province + addComp.city + addComp.district + addComp.street + addComp.streetNumber
        resolve(currentAddress)
      })
    })
  })
}
export default getAddress
